import * as constants from './constants';
import { fromJS } from 'immutable';


const defaultState = fromJS({
    homeData: null
})

const getData = (state, action) => state.set('homeData', action.data);

const reducer = (state = defaultState, action) => {
    // 由于state 是引用类型，不能直接修改，否则监测不到 state 发生变化。所以先拷贝一份，进行编辑
    switch (action.type) {
        case constants.SET_DATA : 
            return getData(state, action);
        default: 
            return state;
    }
}


export default reducer;